from aiogram import F
from aiogram_dialog import Dialog, Window
from aiogram_dialog.widgets.kbd import Start

from src.bot.dialogs.getters.users import user_info_getter, user_is_admin_getter
from src.bot.dialogs.widgets import LocaleText
from src.bot.states import AdminSG, ClientSG
from src.bot.states.user import (
    BuySubscriptionSG,
    CalendarsCatalogSG,
    LanguageSG,
    ManageSubscriptionSG,
    UserCalendarsSG,
    UserProfileSG,
)

start_window = Window(
    LocaleText("welcome", user="{event.from_user.username}"),
    Start(
        LocaleText("buy-subscription-btn"),
        id="buy_subscription",
        state=BuySubscriptionSG.select_subscription_type,
        when=~F["user_have_subscription"],
    ),
    Start(
        LocaleText("manage-subscription-btn"),
        id="manage_subscription",
        state=ManageSubscriptionSG.subscription_info,
        when=F["user_have_subscription"],
    ),
    Start(
        LocaleText("my-profile-btn"), id="my_profile", state=UserProfileSG.show_profile
    ),
    Start(
        LocaleText("calendars-catalog-btn"),
        id="calendars_catalog",
        state=CalendarsCatalogSG.select_category,
    ),
    Start(
        LocaleText("my-calendars-btn"),
        id="my_calendars",
        state=UserCalendarsSG.calendars_list,
        when=F["user_have_subscription"],
    ),
    Start(LocaleText("change-lang-btn"), "change_lang_btn", LanguageSG.select_language),
    Start(
        LocaleText("admin-btn"),
        id="admin_panel",
        when=F["is_admin"],
        state=AdminSG.admin,
    ),
    state=ClientSG.start,
    getter=(user_info_getter, user_is_admin_getter),
)


start_dialog = Dialog(start_window)
